<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>bind方法</title>
</head>

<body>

    <ul>
        <li>bind不会调用函数</li>
        <li>可以改变this指向</li>
        <li>返回由指定的this值和初始化参数改造的原函数拷贝（新函数）</li>
    </ul>

    <button>发送短信</button>
    <script>
        // 需求：发送短信后禁用3s按钮
        const button = document.body.querySelector('button')
        button.addEventListener('click', function () {
            this.disabled = true
            setTimeout(function () {
                this.disabled = false
            }.bind(button) // 改变函数this指向，默认为 window
                , 3000)
        })
    </script>
</body>

</html>